package per.zqx.msrw.ctl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.RestControllerAdvice;
import per.zqx.msrw.domain.UserInfo;
import per.zqx.msrw.service.UserInfoService;

import java.util.UUID;

/**
 * TestCtl,
 *
 * @author Sa, Zhang 2021-12-28 17:38
 */
@RestController
public class TestCtl {

    @Autowired
    UserInfoService userInfoService;

    @GetMapping("master")
    public String master(){
        UserInfo userInfo = new UserInfo();
        userInfo.setName("张仨-" + UUID.randomUUID().toString().substring(0,5));
        userInfoService.insert(userInfo);
        System.out.println(userInfo.toString());
        return userInfo.toString();
    }
    @GetMapping("slave/get/{id}")
    public String slave(@PathVariable("id")Integer id){
        UserInfo userInfo = userInfoService.get(id);
        System.out.println(userInfo.toString());
        return userInfo.toString();
    }
}
